package cn.edu.sgu.www.mhxysy.controller;

import cn.edu.sgu.www.mhxysy.consts.MimeType;
import cn.edu.sgu.www.mhxysy.entity.Phyle;
import cn.edu.sgu.www.mhxysy.restful.JsonResult;
import cn.edu.sgu.www.mhxysy.service.PhyleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author heyunlin
 * @version 1.0
 */
@RestController
@RequestMapping(path = "/phyle", produces = MimeType.APPLICATION_JSON_CHARSET_UTF_8)
public class PhyleController {

    private final PhyleService phyleService;

    @Autowired
    public PhyleController(PhyleService phyleService) {
        this.phyleService = phyleService;
    }

    @RequestMapping(value = "/selectAll", method = RequestMethod.GET)
    public JsonResult<List<Phyle>> selectAll() {
        List<Phyle> list = phyleService.selectAll();

        return JsonResult.success(null, list);
    }

    @RequestMapping(value = "/selectById", method = RequestMethod.GET)
    public JsonResult<Phyle> selectById(@RequestParam Integer id) {
        Phyle phyle = phyleService.selectById(id);

        return JsonResult.success(null, phyle);
    }

}